<script setup>
import {inject} from 'vue'
const str = inject('strKey')
const changeStr = inject('changeStr')
const handleClick = () =>{
  changeStr()
}

</script>

<template>
  <div class="son">
    <h2>孙子组件</h2>
    <p>接收祖先的数据：{{ str }}</p>
    <button @click="handleClick">改变祖先组件str数据</button>
  </div>
</template>

<style scoped>
.son {
    padding: 30px;
    border: 1px solid lightblue;
}
</style>